//引入vue和vuex
import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
const store = new Vuex.Store({ //全局变量定义
	state: {
		user: {},
		isLogin: uni.getStorageSync("uid") ? true : false,
		newChat: {}
	},
	mutations: {
		setUser(state, user) {
			state.user = user;
		},
		updateIslogin(state, value) { // 定义一个名为 increment 的修改状态方法
			state.isLogin = value;
			uni.setStorageSync("isLogin", value);
		},
		setNewChat(state, value) {
			state.newChat = value;
		},
	},
	actions: {
		actionsHandleIsLoginChange(store, param) {
			store.commit('updateIslogin', param)
		},
		actionsHandleUserInfoChange(store, param) {
			store.commit('setUser', param)
		},
		actionsHandleNewChatChange(store, param) {
			store.commit('setNewChat', param)
		},
	}
})
export default store